/* 
 * File:   ExperimentThread.h
 * Author: jcrada
 *
 * Created on April 18, 2009, 9:16 PM
 */

#ifndef _EXPERIMENTTHREAD_H
#define	_EXPERIMENTTHREAD_H

#include "EvolutiveSimulationThread.h"
#include "EvolutionOfMorphologyAndBehavior.h"
#include "Experiment.h"
#include <QtXml/QDomElement>
#include <QtXml/QDomDocument>

namespace jcrada {

    class ExperimentThread : public EvolutiveSimulationThread {
    private:
        Experiment* _experiment;
        Creature* _recorded_creature;

    protected:
        virtual void stabilize(Creature& creature);
        virtual void iterate();
        virtual void analyze();


    public:
        ExperimentThread(EvolutionOfMorphologyAndBehavior& evolution,
                BulletSimulator& simulator = BulletSimulator::getSingleton());
        virtual ~ExperimentThread();
        virtual void run();

        virtual EvolutionOfMorphologyAndBehavior* getEvolution() const {
            return dynamic_cast<EvolutionOfMorphologyAndBehavior*> (EvolutiveSimulationThread::getEvolution());
        }

        virtual void setExperiment(Experiment& experiment) {
            this->_experiment = &experiment;
        }

        virtual Experiment& getExperiment() const {
            return *this->_experiment;
        }
        static int main(int argc, char** argv);

    };
}

#endif	/* _EXPERIMENTTHREAD_H */

